﻿//using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.Text;
//using IBatisNet.DataMapper;
//using IBatisNet.DataMapper.Configuration;
//using Framework.Common.Configs;
//using IBatisNet.DataMapper.SessionStore;

//namespace Framework.Mybatis
//{
//    /// <summary>
//    /// SqlMap创建管理
//    /// </summary>
//    class SqlMapperManager
//    {
//        private static IDictionary<String, ISqlMapper> dictMappers;

//        static SqlMapperManager()
//        {
//            dictMappers = new Dictionary<String, ISqlMapper>();
//        }

//        /// <summary>
//        /// 实例化SqlMap对象
//        /// </summary>
//        /// <param name="mapperName">通常.config文件</param>
//        /// <returns></returns>
//        public static ISqlMapper GetMapper(String sqlmapperName)
//        {
//            if (dictMappers.ContainsKey(sqlmapperName))
//            {
//                return dictMappers[sqlmapperName];
//            }
//            else
//            {
//                string mapperName = CustomConfigRoot.ConfigRootPath + sqlmapperName + ".SqlMap.config";
//                var mapper = new DomSqlMapBuilder().ConfigureAndWatch(mapperName, RebuildConfig);
//                mapper.SessionStore = new HybridWebThreadSessionStore(mapper.Id);
//                lock (typeof(SqlMapperManager))
//                {
//                    if (!dictMappers.ContainsKey(sqlmapperName))
//                        dictMappers.Add(sqlmapperName, mapper);
//                }
//                return mapper;
//            }
//        }

//        private static void RebuildConfig(object obj)
//        {
//            dictMappers = new Dictionary<String, ISqlMapper>();
//        }
//    }
//}
